import React from 'react';
import BaseComponent from '../Base/BaseComponent';
import {Col, Form, Row} from 'antd';
import Immutable from 'immutable'
import CommonUtil from '../../utils/CommonUtil';
import {withRouter} from "react-router-dom";
import connect from "react-redux/es/connect/connect";

class HomeUser extends BaseComponent {
    constructor() {
        super();

        this.state = {
            stat: Immutable.fromJS({}),
        }
    }

    componentWillReceiveProps(nextProps) {
        this.setState({stat: nextProps.stat})
    }

    render() {
        return (
            <div className="margin-top-20 person-info ">
                <Row gutter={20}>
                    <Col md={{span: 24}} lg={{span: 24}} xl={14}>
                        <div className="person-pic-info flex-box margin-top-20">
                            <div className="person-pic-box">
                                    <span className="ant-avatar ant-avatar-info ant-avatar-circle ant-avatar-image">
                                        <img
                                            src={this.props.user.get('avatar') || "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"}/>
                                    </span>
                            </div>
                            <div className="person-pic-text">
                                <div className="person-pic-tit">
                                    <span>{this.props.user.get('nickname') || this.props.user.get('account')}</span>&nbsp;{CommonUtil.parseDayHello()}&nbsp;欢迎回来~
                                </div>
                                <div>伟大的工作，并不是用力量而是用耐心去完成的！</div>
                            </div>
                        </div>
                    </Col>
                    <Col md={{span: 24}} lg={{span: 24}} xl={10}>
                        <div className="extraContent-box flex-box  margin-top-20">
                            {/*<div className="statItem-list">*/}
                            {/*    <p>已受理订单数</p>*/}
                            {/*    <p>{this.state.stat.get('myOrderCount', 0)}</p>*/}
                            {/*</div>*/}
                            {/*<div className="statItem-list">*/}
                            {/*    <p>已受理订单总额</p>*/}
                            {/*    <p><span>{CommonUtil.formatMoney(this.state.stat.get('myTotalPrice', 0))}</span></p>*/}
                            {/*</div>*/}
                            {/*<div className="statItem-list">*/}
                            {/*    <p>在线时长</p>*/}
                            {/*    <p>{this.state.stat.get('myTotalOnline', 0)}</p>*/}
                            {/*</div>*/}
                        </div>
                    </Col>
                </Row>
            </div>
        )
    }
}


export default withRouter(connect(
    state => ({
        user: state.root.user,
    })
)(Form.create()(HomeUser)))
